import React from 'react'
import { useNavigate } from "react-router-dom";


const userList = ["zhangsan","lisi","wangwu"];

export default function Login() {
    const navigate = useNavigate();
    const login = function (e) {
        if (e.keyCode === 13) {
            if (userList.includes(e.target.value))
                {
                localStorage.setItem('token', e.target.value);
                navigate(-1);//后退,返回
            }
            else alert("账号不正确")
        }
    }
    
  return (
      <div>
          <h3>登录界面</h3>
          <input onKeyUp  ={login} type="text" />
    </div>
  )
}
